all files / iconMenu/ iconMenu.vue

37.5% Statements 9/24
50% Branches 4/8
10% Functions 1/10
22.22% Lines 4/18
1 branch Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116                              1× 1× 1×                                                                                                                                                                                                    
//
//
//
//
//
//
//
//
//
//
//
//
//
//
 
import iconButton from '../iconButton'
import popover from '../popover'
import {menu} from '../menu'
export default {
  name: 'mu-icon-menu',
  props: {
    icon: {
      type: String,
      required: true
    },
    value: {},
    multiple: {
      type: Boolean,
      default: false
    },
    desktop: {
      type: Boolean,
      default: false
    },
    open: {
      type: Boolean,
      default: false
    },
    maxHeight: {
      type: Number
    },
    anchorOrigin: {
      type: Object,
      default () {
        return {
          vertical: 'top',
          horizontal: 'left'
        }
      }
    },
    targetOrigin: {
      type: Object,
      default () {
        return {
          vertical: 'top',
          horizontal: 'left'
        }
      }
    },
    scroller: {
      type: [HTMLDocument, Element, Window]
    },
    itemClickClose: {
      type: Boolean,
      default: true
    },
    tooltip: {
      type: String
    },
    tooltipPosition: {
      type: String,
      default: 'bottom-center'
    }
  },
  data () {
    return {
      openMenu: this.open,
      trigger: null
    }
  },
  methods: {
    handleOpen () {
      this.openMenu = true
      this.$emit('open')
    },
    handleClose () {
      this.openMenu = false
      this.$emit('close')
    },
    change (value) {
      this.$emit('change', value)
    },
    itemClick (item) {
      if (this.itemClickClose) {
        this.handleClose()
      }
      this.$emit('itemClick', item)
    }
  },
  mounted () {
    this.trigger = this.$el
  },
  watch: {
    open (val, oldVal) {
      if (val === oldVal) return
      this.openMenu = val
    }
  },
  components: {
    'icon-button': iconButton,
    popover,
    'mu-menu': menu
  }
}